#include <bits/stdc++.h>
using namespace std;

int n, a[10];
bool f, ina[10] = {0};
int t, cnt = 0, i1, i2, i3, i4, i5, n1, n2, n3, n4, n5, tj1, j2, j3;

int main(){
	cin >> n;
	for (int i = 1; i <= n; i++){
		cin >> a[i];
		ina[a[i]] = 1;
	}
	for (i1 = 1; i1 <= n; i1++){
		n1 = a[i1];
		for (i2 = 1; i2 <= n; i2++){
			n2 = a[i2];
			for (i3 = 1; i3 <= n; i3++){
				n3 = a[i3];
				for (i4 = 1; i4 <= n; i4++){
					n4 = a[i4];
					for (i5 = 1; i5 <= n; i5++){
						n5 = a[i5];
						tj1 = (n1 * 100 + n2 * 10 + n3) * n5;
						j2 = (n1 * 100 + n2 * 10 + n3) * n4;
						j3 = tj1 + 10 * j2;
						f = 1;
//						printf("%d%d%d %d%d =>%5d%5d => %5d --> f=", n1, n2, n3, n4, n5, tj1, j2, j3);
						if (tj1 >= 1000 || j2 >= 1000 || j3 >= 10000) f = 0;
						for (t = 1; t <= 3; t++){
							if (!f || !ina[tj1 % 10]){
								f = 0;
								break;
							}
							tj1 /= 10;
						}
						for (t = 1; t <= 3; t++){
							if (!f || !ina[j2 % 10]){
								f = 0;
								break;
							}
							j2 /= 10;
						}
						for (t = 1; t <= 4; t++){
							if (!f || !ina[j3 % 10]){
								f = 0;
								break;
							}
							j3 /= 10;
						}
						cnt += f;
//						cout << f << endl;
					}
				}
			}
		}
	}
	cout << cnt;
	return 0;
}
